# $Id$
# Maintainer: Dave Reisner <dreisner@archlinux.org>
# Contributor: Stéphane Gaudreault <stephane@archlinux.us>
# Contributor: Daniel J Griffiths <ghost1227@archlinux.us>
# Contributor: damir <damir@archlinux.org>

pkgname=time
pkgver=1.7.2
pkgrel=1
pkgdesc="Utility for monitoring a program's use of system resources"
arch=('i686' 'x86_64')
url="https://directory.fsf.org/wiki/Time"
license=('GPL')
depends=('glibc')
source=(http://git.savannah.gnu.org/cgit/time.git/snapshot/time-$pkgver.tar.gz
        time-1.7-Recompute-CPU-usage-at-microsecond-level.patch
        time-1.7-ru_maxrss-is-in-kilobytes-on-Linux.patch)
sha1sums=('d1c00075edf3d9ab422b5e8119cf7c865d1e91e6'
          'fff80e05dd41f0a59bb1f49d1c6e581d5e8e92e5'
          'b2a909e1d92f7af1bc99a4524ad84d467ed79a06')

prepare() {
  cd "$pkgname-$pkgver"

  # cf https://bugzilla.redhat.com/show_bug.cgi?id=527276
  patch -Np1 < "$srcdir"/time-1.7-Recompute-CPU-usage-at-microsecond-level.patch

  # cf https://bugzilla.redhat.com/show_bug.cgi?id=702826
  patch -Np1 < "$srcdir"/time-1.7-ru_maxrss-is-in-kilobytes-on-Linux.patch

  # rebuild the ancient autoconf setup to fix a variety of build issues
  # surrounding missing/incorrect includes.
  autoreconf -fisv
}

build() {
  cd "$pkgname-$pkgver"

  ./configure --prefix=/usr --infodir=/usr/share/info
  make
}

package() {
  cd "$pkgname-$pkgver"

  make exec_prefix="$pkgdir/usr" infodir="$pkgdir/usr/share/info" install
}
